package app.maker.entity;

import java.io.Serializable;

import javax.persistence.*;

import java.util.Date;
import java.util.List;


/**
 * The persistent class for the user database table.
 * 
 */
@Entity
@Table(name="user")
@NamedQueries({
	@NamedQuery(name="User.findAll", query="SELECT u FROM User u"),
	@NamedQuery(name = "User.findUserByLogin", query = "SELECT u FROM User u WHERE u.login = :param") })
public class User implements Serializable {
	private static final long serialVersionUID = 1L;
	private int id;
	private String adresse;
	private Date dateArrivee;
	private String email;
	private String fonction;
	private String login;
	private String motDePasse;
	private String nom;
	private String photo;
	private String prenom;
	private int role;
	private float salaire;
	private byte statut;
	private List<Entree> entrees;
	private List<Sortie> sorties;
	private List<TicketHasUser> ticketHasUsers;

	public User() {
	}


	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(unique=true, nullable=false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	@Column(nullable=false, length=255)
	public String getAdresse() {
		return this.adresse;
	}

	public void setAdresse(String adresse) {
		this.adresse = adresse;
	}


	@Temporal(TemporalType.DATE)
	@Column(nullable=false)
	public Date getDateArrivee() {
		return this.dateArrivee;
	}

	public void setDateArrivee(Date dateArrivee) {
		this.dateArrivee = dateArrivee;
	}


	@Column(length=255)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}


	@Column(nullable=false, length=255)
	public String getFonction() {
		return this.fonction;
	}

	public void setFonction(String fonction) {
		this.fonction = fonction;
	}


	@Column(nullable=false, length=20, unique=true)
	public String getLogin() {
		return this.login;
	}

	public void setLogin(String login) {
		this.login = login;
	}


	@Column(nullable=false, length=50)
	public String getMotDePasse() {
		return this.motDePasse;
	}

	public void setMotDePasse(String motDePasse) {
		this.motDePasse = motDePasse;
	}


	@Column(nullable=false, length=45)
	public String getNom() {
		return this.nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}


	@Column(length=255)
	public String getPhoto() {
		return this.photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}


	@Column(length=45)
	public String getPrenom() {
		return this.prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}


	@Column(nullable=false)
	public int getRole() {
		return this.role;
	}

	public void setRole(int role) {
		this.role = role;
	}


	@Column(nullable=false)
	public float getSalaire() {
		return this.salaire;
	}

	public void setSalaire(float salaire) {
		this.salaire = salaire;
	}


	@Column(nullable=false)
	public byte getStatut() {
		return this.statut;
	}

	public void setStatut(byte statut) {
		this.statut = statut;
	}


	//bi-directional many-to-one association to Entree
	@OneToMany(mappedBy="user")
	public List<Entree> getEntrees() {
		return this.entrees;
	}

	public void setEntrees(List<Entree> entrees) {
		this.entrees = entrees;
	}

	public Entree addEntree(Entree entree) {
		getEntrees().add(entree);
		entree.setUser(this);

		return entree;
	}

	public Entree removeEntree(Entree entree) {
		getEntrees().remove(entree);
		entree.setUser(null);

		return entree;
	}


	//bi-directional many-to-one association to Sortie
	@OneToMany(mappedBy="user")
	public List<Sortie> getSorties() {
		return this.sorties;
	}

	public void setSorties(List<Sortie> sorties) {
		this.sorties = sorties;
	}

	public Sortie addSorty(Sortie sorty) {
		getSorties().add(sorty);
		sorty.setUser(this);

		return sorty;
	}

	public Sortie removeSorty(Sortie sorty) {
		getSorties().remove(sorty);
		sorty.setUser(null);

		return sorty;
	}


	//bi-directional many-to-one association to TicketHasUser
	@OneToMany(mappedBy="user", cascade= CascadeType.ALL)
	public List<TicketHasUser> getTicketHasUsers() {
		return this.ticketHasUsers;
	}

	public void setTicketHasUsers(List<TicketHasUser> ticketHasUsers) {
		this.ticketHasUsers = ticketHasUsers;
	}

	public TicketHasUser addTicketHasUser(TicketHasUser ticketHasUser) {
		getTicketHasUsers().add(ticketHasUser);
		ticketHasUser.setUser(this);

		return ticketHasUser;
	}

	public TicketHasUser removeTicketHasUser(TicketHasUser ticketHasUser) {
		getTicketHasUsers().remove(ticketHasUser);
		ticketHasUser.setUser(null);

		return ticketHasUser;
	}

}